package com.fly.lambda.dao;

import com.fly.lambda.domain.Article;
import com.fly.lambda.framework.dao.BaseDAO;
import com.fly.lambda.framework.dao.Pagination;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Fly on 2016/8/1.
 */
@Repository
public class ArticleDAO extends BaseDAO<Article> {

    public Pagination<Article> queryArticleByChannel(String channelId, int curPage, int pageSize){
        StringBuilder hql = new StringBuilder();
        hql.append(" from Article where channelId = ? order by top, order_num desc");
        return doQueryPage(hql.toString(), true, curPage, pageSize, channelId);
    }

    public List<Article> getRecommendArticle(int count){
        StringBuilder hql = new StringBuilder();
        hql.append(" from Article order by top, order_num desc");
        return doQueryLimitList(hql.toString(), true, 1, count);
    }

    public List<Article> getRelationArticle(String channelId, String articleId, int count){
        StringBuilder hql = new StringBuilder();
        hql.append(" from Article where channel_id = ? and article_id <> ? order by top, order_num desc");
        return doQueryLimitList(hql.toString(), true, 1, count, channelId, articleId);
    }

//    public Pagination<Article> queryArticle(String )

}
